# 测试禁用think内容过滤后的效果

Write-Host "=== 测试禁用think内容过滤 ===" -ForegroundColor Green

$baseUrl = "http://localhost:8082/api/ollama"

Write-Host "`n🔧 修改内容:" -ForegroundColor Yellow
Write-Host "1. 流式方法：直接发送原始数据块，不进行think内容过滤" -ForegroundColor White
Write-Host "2. 非流式方法：直接返回原始响应，不进行think内容过滤" -ForegroundColor White
Write-Host "3. 前端将显示完整的AI回答，包括<think>标签内容" -ForegroundColor White

Write-Host "`n🧪 测试1: 非流式接口..." -ForegroundColor Cyan

try {
    $body = @{
        prompt = "你是谁？请简单介绍一下自己。"
    } | ConvertTo-Json

    Write-Host "发送非流式请求..." -ForegroundColor Gray
    Write-Host "URL: $baseUrl/chat" -ForegroundColor Cyan
    
    $response = Invoke-RestMethod -Uri "$baseUrl/chat" -Method POST -Body $body -ContentType "application/json" -TimeoutSec 60
    
    Write-Host "`n非流式响应结果:" -ForegroundColor Yellow
    Write-Host "=" * 60 -ForegroundColor Gray
    Write-Host $response -ForegroundColor Green
    Write-Host "=" * 60 -ForegroundColor Gray
    
    if ($response -match "<think>") {
        Write-Host "✅ 检测到<think>标签，过滤已成功禁用" -ForegroundColor Green
    } else {
        Write-Host "ℹ️  未检测到<think>标签，可能模型没有生成思考内容" -ForegroundColor Yellow
    }

} catch {
    Write-Host "❌ 非流式测试失败: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`n🧪 测试2: 流式接口..." -ForegroundColor Cyan

try {
    $body = @{
        prompt = "请详细分析一下Spring Boot的优势，并思考一下它的应用场景。"
    } | ConvertTo-Json

    Write-Host "发送流式请求..." -ForegroundColor Gray
    Write-Host "URL: $baseUrl/chat-stream" -ForegroundColor Cyan
    Write-Host "请求体: $body" -ForegroundColor Gray
    
    Write-Host "`n开始接收流式响应（应该包含完整内容）:" -ForegroundColor Yellow
    Write-Host "=" * 60 -ForegroundColor Gray

    # 使用curl来测试流式输出，可以看到实时效果
    $curlCommand = "curl -N -X POST `"$baseUrl/chat-stream`" -H `"Content-Type: application/json`" -d '$body'"
    Write-Host "执行命令: $curlCommand" -ForegroundColor Gray
    Write-Host ""
    
    # 执行curl命令
    Invoke-Expression $curlCommand
    
    Write-Host "`n=" * 60 -ForegroundColor Gray
    Write-Host "✅ 流式测试完成" -ForegroundColor Green

} catch {
    Write-Host "❌ 流式测试失败: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`n📋 测试结果分析:" -ForegroundColor Magenta
Write-Host "- 如果看到<think>...</think>标签和内容，说明过滤已成功禁用" -ForegroundColor White
Write-Host "- 如果流式输出包含完整的AI思考过程，说明修改生效" -ForegroundColor White
Write-Host "- 前端现在应该能看到AI的完整思考和回答过程" -ForegroundColor White

Write-Host "`n🌐 建议进一步测试:" -ForegroundColor Magenta
Write-Host "1. 打开浏览器访问: http://localhost:8082/stream.html" -ForegroundColor White
Write-Host "2. 测试普通模式和流式模式" -ForegroundColor White
Write-Host "3. 观察是否能看到完整的AI思考过程" -ForegroundColor White
Write-Host "4. 检查前端是否正常显示<think>标签内容" -ForegroundColor White

Write-Host "`n💡 如果需要重新启用过滤:" -ForegroundColor Magenta
Write-Host "- 可以随时修改代码重新启用think内容过滤功能" -ForegroundColor White
Write-Host "- 或者添加一个配置参数来动态控制是否过滤" -ForegroundColor White
